#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    string addBinary(string a, string b) {
        string ret;
        int t = 0, a1 = a.size() - 1, b1 = b.size() - 1;
        while (a1 >= 0 || b1 >= 0 || t)
        {
            if (a1 >= 0) t += a[a1--] - '0';
            if (b1 >= 0) t += b[b1--] - '0';
            ret.push_back(t % 2 + '0');
            t /= 2;
        }
        reverse(ret.begin(), ret.end());
        return ret;
    }
};